<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /*
        常用对象：
         -Date 日期对象
         */


        setInterval(function () {
            //通过构造函数创建Date对象
            var now = new Date();//现在
            //var date = new Date("2020/01/01");//设置某个日期对象
            console.log(now);

            //通过日期对象获得相关的信息
            var year = now.getFullYear() + "年";
            console.log(year);
            var month = now.getMonth() + 1 + "月";
            console.log(month);
            var date = now.getDate() + "日"
            console.log(date);
            console.log(now.getDay());//星期
            var hour = now.getHours() + "时";
            var minutes = now.getMinutes() + "分";
            var seconds = now.getSeconds() + "秒";

            //document.write(year + month + date + hour + minutes + seconds);
            //向body中设置内容 直接覆盖之前的
            document.body.innerHTML=year + month + date + hour + minutes + seconds;
        }, 1000)












    </script>
</head>

<body>

</body>

</html>